﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Clandestine.Graphics
{
    // Yup, keys have to be unique. So, all depths are now unique.
    // Renderable puts effort into finding you the closest possible unique depth to what you set.
    // Don't worry, It Just Works.
    public class RenderList : SortedList<decimal, Renderable>
    {
    	public Graphics Graphics;
    	
    	public RenderList(Graphics g) : base()
    	{
    		this.Graphics = g;
    	}
    	
        public void Add(Renderable renderable)
        {
            this.Add(renderable.Depth, renderable);
        }

        public void Remove(Renderable renderable)
        {
            this.Remove(renderable.Depth);
        }

        public bool Contains(Renderable renderable)
        {
			return this.ContainsValue(renderable);
        }
        
        public void Dispose()
        {
        	foreach (decimal depth in this.Keys.ToArray())
        		this[depth].Dispose();
        }
    }
}
